home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / Papers / aSEPiA example source / plugin / Plugin 1 / CInterfaceProvider.cpp next >
Encoding:
C/C++ Source or Header  |  1999-06-25  |  1.0 KB  |  52 lines  |  [TEXT/CWIE]

  1. /*---------------------------------------------------------------
  2.  
  3.     CInterfaceProvider.cpp
  4.     
  5.     Provides the function of returning interface pointers based on
  6.     passed in IDs.
  7.  
  8. ---------------------------------------------------------------*/
  9.  
  10. #include "IInterfaceProvider.h"
  11. #include "CInterfaceProvider.h"
  12.  
  13. #include "CPluginInfo.h"
  14. #include "CPluginDrawing.h"
  15.  
  16. CInterfaceProvider::CInterfaceProvider()
  17.     :mDrawObject(0), mInfoObject(0)
  18. {
  19.  
  20. }
  21.  
  22. OSErr    CInterfaceProvider::GetInterfacePointer( unsigned long inID, void** outInterfacePtr )
  23. {
  24.     OSErr    returnValue = noErr;
  25.     
  26.     // create an object based on the passed in ID
  27.     switch( inID ){
  28.         case IPluginInfo_ID:
  29.         {
  30. //            if ( mInfoObject == 0 ){
  31.                 mInfoObject =  (IPluginInfoIntf*) new CPluginInfo();    
  32. //            }
  33.             *outInterfacePtr = mInfoObject;
  34.         } break;
  35.         
  36.         case IPluginDraw_ID:
  37.         {
  38. //            if ( mDrawObject == 0 ) {
  39.                 mDrawObject = (IPluginDrawIntf*)new CPluginDrawing();
  40. //            }
  41.             *outInterfacePtr = mDrawObject;
  42.         } break;
  43.         
  44.         default:
  45.         {
  46.             returnValue = 1; // an error occured
  47.         };
  48.     
  49.     }
  50.     
  51.     return returnValue;
  52. }